#include<iostream> 
using namespace std;
const int N = 1e6 + 10;
typedef long long LL;
LL a[N];
LL n, m;
int main()
{
	cin >> n >> m;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
	}
	LL left = 1, right = 2e9;
	while(left < right)
	{
		LL mid = left + (right - left + 1) / 2;
		LL ret = 0;
		for(int i = 1; i <= n; i++)
		{
			if(a[i] > mid) ret += a[i] - mid;
		}
		if(ret >= m) left = mid;
		else right = mid - 1;
	}
	cout << left << endl;
	return 0;
}
